#include "common.h"

int pivotIndex(vector<int>& nums)
{
	int n = nums.size();
	vector<int> sum(n + 1, 0);
	for (int i = 0; i < n; i++)
	{
		sum[i + 1] = sum[i] + nums[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (sum[i] - sum[0] == sum[n] - sum[i + 1]) return i;
	}
	return -1;
}
